package org.cinvestav.computacion.matias.onlyangel.datos;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class Texturas {
	public int W,H;
	public Peso textura[][];
	public Document texturasDoc;

	public Texturas(int w,int h) {
		int n,u;
		W=w;
		H=h;
		textura = new Peso[w][h];
		for (n=0;n<w;n++){
			for (u=0;u<h;u++){
				textura[n][u] = new Peso();
			}
		}
	}

	public void setDocument(Document text){
		texturasDoc = text;
	}
	public void setFile(String str){
		try{
			DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
			DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();
			texturasDoc=docBuilder.parse(new File("jugada.xml"));



		}catch(SAXParseException err){
			System.out.println("** Parsing error, line "+err.getLineNumber()+", uri "+err.getSystemId());
			System.out.println(" "+err.getMessage());
		}catch(SAXException ie){
			Exception x=ie.getException();
			((x==null) ? ie : x).printStackTrace();
		}catch(Throwable t){
			t.printStackTrace();
		}

	}

	public void setFile(File f){
		try{
			DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
			DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();
			texturasDoc=docBuilder.parse(f);
			
			
			
		}catch(SAXParseException err){
			System.out.println("** Parsing error, line "+err.getLineNumber()+", uri "+err.getSystemId());
			System.out.println(" "+err.getMessage());
		}catch(SAXException ie){
			Exception x=ie.getException();
			((x==null) ? ie : x).printStackTrace();
		}catch(Throwable t){
			t.printStackTrace();
		}
	}
	
	public void parseaElDocumento(){
		
	}
}
